package com.itheima.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo02 {

    public static void main(String[] args) throws InterruptedException {
        //最大线程数量的线程池 最多有多少个线程在干活
        ExecutorService pool = Executors.newFixedThreadPool(5);
        //没有上限  来多少个任务 (瞬时) 有多少个线程干活
        //ExecutorService pool = Executors.newCachedThreadPool();
        for (int i = 0; i < 10; i++) {
            //Thread.sleep(100);
            pool.submit(()->{
                String name = Thread.currentThread().getName();
                System.out.println(name+"执行了");
            });
        }



    }
}
